You are here:   HomeC Programming (Theory)Basic Of C Prog.Write a C program to read formatted data from stdin: how to use scanf.
by Dinesh Thakur Category: Basic Of C Programming

 

 

#include<stdio.h>
#include<conio .h>
void main()
{
char str[80];
int i;
printf("Enter your last name: ");
scanf("%s",str);
printf("Enter your age: ");
scanf("%d",&i);
printf("Last Name = %s, age = %d .\n",str,i);
printf("Enter a hexadecimal number: ");
scanf("%x",&i);
printf("You have entered %#x (%d).\n",i,i);
getch();
}
 
OUTPUT:

Enter your last name: Singh Enter your age: 24
Last Name = Singh, age = 24.
Enter a hexadecimal nurnber: 4012
You have entered 0*4012 (16402).


Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article