You are here:   HomeC Programming (Theory)Basic Of C Prog.Write A C Program For A Freestanding Block Statement.
by Dinesh Thakur Category: Basic Of C Programming

 

 

#include<stdio.h>
#include<conio.h>
void main()
{
char initial = ‘ ‘;
char name[80] = {0};
char age[4] = {0};
printf("Your first initial: ");
scanf("%c", &initial);
printf("Your first name:");
scanf("%s", name);
if(initial != name[0])
printf("\n%s,you got your initial wrong.", name);
else
printf("\nHi, %s. Your initial is correct. ", name); printf("\n Your full name and your age separated by a comma:\n");
scanf("%[^,], %[0123456789]", name, age);
printf("\n Your name is %s and you are %s years old\n", name, age);
getch();
}
 
OUTPUT:
 
Your first initial: i
Your first name: Ikvinder
Hi, Ikvinder. Your initial is correct.
Your full name and your age separated by a comma:
Ikvinder Pal Singh, 24
Your name is Ikvinder Pal Singh and you are 24 years old


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