C Program
C Program
my.c
#include<stdio.h>
void main()
{
printf("Name : John");
getch(); //to add a Pause
}
So if you want to know Write a Program to Display your Name in C then you
need to Write Print function inside your C Program and between the Print
functions double Quotes you need to write your Name.
Usually getch() (getch function) is used to read a character from screen. But
here we are using this to add a Pause to our Output Screen. If we don’t add
this in our program, our program’s output screen will close quickly after
running our program.
clrscr( ):
When we run our C Program for 1st time we Get our value. but after making
some changes to our C program when we run the program we get out new
output with the old output.
To remove those Old/Previews Output/Results values, We use clrscr();.
Where clr(Clear) and scr(Screen) stands for Clear Screen (clrscr).
my.c
#include<stdio.h>
void main()
{
printf( " My Name Is Human " );
getch();
}
For your Question “C Program to input name and Display“, We have to get
user input first then we have to Store and Display user Input at the END.
For this we are going to use scanf() function.
and a variable where we will store input data like Name.
Below we have a C Program where we will get Name from user input and
after that we will display entered name at the End
my.c
#include<stdio.h>
void main()
{
char name[20];
printf("Enter Your Name : ");
scanf("%s",&name);
printf("Your name is : %s", name);
getch();
}
Write a program to Print your name in c
Here is a C Program that can display your given name when you run this C
Program.
We have used printf() function to Print your Name.
my.c
#include<stdio.h>
void main()
{
printf("My Name is John");
getch();
}
You also can use clrscr() Clear Screen C Function before print() Function to
clear old outputs.
To print your Name or Address we can use Same C Print Function (printf())
for both.
Just write your name inside The C Function
[ printf(“Name and Address“); ].
my.c
#include<stdio.h>
void main()
{
printf("My Name is John and My Address is : 21 Jump Street NewYork");
getch(); //add a Pause
}
Write a program to print your name at the center of the screen
To print or write a program to print your name at the center of the screen.
We have to use C Language’s gotoxy() function.
Where we need to provide X and Y digits to Perfectly align our Name at the
Center of the Screen.
my.c
#include<stdio.h>
void main()
{
gotoxy(40,13);
printf("Rosie");
getch();
}
write a c program to display your name
my.c
#include<stdio.h>
void main()
{
clrscr();
printf("My Name is John");
getch();
}
I am not able to Understand this Question. So i will assume that You want a
Program to Print Names.
So if this is your Question, Then above we have so many Programs to do that.
But if you want to know what name or how we can Name our program that
will print our name, Then its so simple.
Just flick “File” Option from the Menu
From there Select “Save” Option
(if nothing is happening the select “Save As” Instead of “Save”)
Give a Name for your file Followed by .c Extortion.
for Example : myfile.c
Now select Done or Save.
my.c
#include<stdio.h>
void main()
{
clrscr();
printf("My Name is John");
getch();
}
name in c language
my.c
#include <stdio.h>
int main()
{
char name[20] = "John";
printf("My name is %s", name);
printf("\nMy name is John without Variable");
getch();
}
& name in c
We we are storing names using C Scanf function then we use this “&” sign or
&name in c.
Where &name will store input data to given variable (which is name).
my.c
#include <stdio.h>
int main()
{
char name[20];
printf("Enter your Name\n");
scanf("%s",&name);
printf("\nYour name is = %s",name);
getch();
}
c program to print name using array
When we store our name inside the C Character datatype. Then to store all
the character we give array length after the variable name (name[10]).
So we can say that we are storing our name using arrays.
But if you want to store your name in the array manually then you can also
do that.
But the problem is, we have to run C Loop to print every single Character
from our name.
my.c
#include<stdio.h>
void main()
{
char name[] = {'j','o','h','n'};
int i=0;
while(i<sizeof(name)){
printf("%c",name[i]);
i++;
}
getch();
}
How to input a name in c
my.c
#include <stdio.h>
int main()
{
char name[20];
printf("Enter your Name\n");
scanf("%s",&name);
printf("\nYour name is = %s",name);
getch();
}
write a program to enter your name and print it
my.c
#include <stdio.h>
int main()
{
char name[20];
printf("Enter your Name\n");
scanf("%s",&name);
printf("\nYour name is = %s",name);
getch();
}
To print Name and Age we have to deal with Characters and Integer values.
Where for storing Character Values we have CHAR data type
and for integers with have INT data type.
And for address/format specifier we have %s for String and %d for
Integers/Digits.
Here here is the C Program display name and Age.
my.c
#include<stdio.h>
int main()
{
char name[20];
int age;
printf("Enter your Name\n");
scanf("%s",&name);
printf("\nEnter your Age\n");
scanf("%d",&age);
printf("\nYour name is = %s",name);
printf("\nYou are %d Years OLD",age);
getch();
}
But if you don’t want to get and store the Age and Name then you can insert
or give the AGE and NAME manually.
my.c
#include <stdio.h>
int main()
{
char name[20] = "John";
int age = 25;
printf("\nYour name is = %s",name);
printf("\nYou are %d Years OLD",age);
getch();
}
and if you don’t even want to use Variables the write all the Info about name
and age inside C Printf function.
my.c
#include<stdio.h>
int main()
{
printf("\nMy name is = John");
printf("\nI am 25 Years OLD");
getch();
}