Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

C Chapter 4

Q. What is gets() and puts() in C?

Ans:- gets() is a string input function belongs to "stdio.h" header file. It accept the input till we not press the Carriage Return (Enter) Key. It also accept the space as an input. gets() accept a single argument and a line of text from standard input device.
e.g. 
#include<stdio.h>
#include<conio.h>
void main()
{
char line[100];
clrscr();
printf("Write something about yourself = ");
gets(line);
printf("\nAbout Yourself %s",line);
}

puts() is a string output function belongs to "stdio.h" header file. It also insert the '\n' automatically at the end of line.
e.g.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
puts("Welcome at ZKing Institute");
printf("Visit Again");
}

Q. Define the Variable and Constants in C.
Ans:- Variable is use for to store the value temprarely. When we declare a variable it take some location into memory as per data type. We can change the value of variable during the execution of program. A variable always be declare with there data type before using. There are some rules which me must have to follow at the time of variable declaration given below:

1. Variable names are case sensitive. Means int a,A; are both two differ variables.
2. A variable name should be start from character or underscore.
e.g. int age, _age;
3. Any sign except underscore is not allowed in variable name.
4. A number can use in variable name but not in beginning. 
e.g. int h20;
5. Any keyword can't be use as a variable.
6. White space/space is not allowed in variable name.

Constant is also use for store the value, but value of constant can't be change during the execution of program.  A constant is declare with 'const' keyword and value is also put in it during the declaration e.g.
const float tax=10.04;

No comments:

Post a Comment