Professional Documents
Culture Documents
2. What is keyboards.
:> Keywords are predefined or reserved words that have special meanings to the
compiler
3. Syntax of if condition
:> if (condition) {
// block of code to be executed if the condition is true
}
4. What is Pointer?
:> A pointer is a variable that stores the address of another variable. Unlike
other variables that hold values of a certain type, pointer holds the address of a
variable.
:> An array is a variable that can store multiple values. For example, if you want
to store 100 integers, you can create an array for it. int data[100];
:> .c
:>An operating system is a software package that runs applications and serves as a
communication link (interface) between the computer hardware and the user
:> the process in which the program repeats a certain section of code in a similar
way
:> The most common loop statements in C are the for loop, the while loop, and the
do-while loop.
:> The assignment operator is used to assign the value, variable and function to
another variable
19. What are the conditional statements write with syntax of any one.
:> A conditional statement is represented in the form of “if…then”. Let p and q are
the two statements, then statements p and q can be written as per different
conditions, such as; p implies q. p is sufficient for q.
20. Which shortcut keys are used to execute and compile the program?
:> ctrl-F9.
:> Alphabets.
Digits.
Special characters.
White space.
Code:
C
/** //Documentation
* file: age.c
* author: you
* description: a program to find our age.
*/
#include <stdio.h> //Link
#define BORN 2000 //Definition
int age(int current); //Global Declaration
int main(void) //Main() Function
{
int current = 2021;
printf("Age: %d", age(current));
return 0;
}
int age(int current) { //Subprograms
return current - BORN;
}
// main function -
// where the execution of program begins
int main()
{
return 0;
}
#include<stdio.h>
int a=50, b=40;
void main()
{
printf("a = %d and b=%d",a,b);
}
:> As the name suggests, a constant in C is a variable that cannot be modified once
it is declared in the program. We can not make any change in the value of the
constant variables after they are defined.
int main()
{
return 0;
}
:> Relational operators compare values and return either TRUE or FALSE. Logical
operators perform logical operations on TRUE and FALSE. Values used with a logical
operator are converted into booleans prior to being evaluated.
:> A compiler takes our source code and generates the corresponding assembly code.
An assembler converts the assembly code to the machine code. A linker merges all
the machine-code modules referenced in our code
:> Primitive Data Types Primitive data types are the most basic data types that are
used for representing simple values such as integers, float, characters, etc.
User Defined Data Types The user-defined data types are defined by the user
himself.
Derived Types The data types that are derived from the primitive or built-in
datatypes are referred to as Derived Data Types.
17. Write a short note on switch case with syntax and example.
:> Switch case statements follow a selection-control mechanism and allow a value to
change control of execution.
They are a substitute for long if statements that compare a variable to several
integral values.
The switch statement is a multiway branch statement. It provides an easy way to
dispatch execution to different parts of code based on the value of the expression.
In C, the switch case statement is used for executing one condition from multiple
conditions. It is similar to an if-else-if ladder.
switch(expression)
{
case value1: statement_1;
break;
case value2: statement_2;
break;
.
.
.
case value_n: statement_n;
break;
default: default_statement;
}
:> Primitive Data Types Primitive data types are the most basic data types that are
used for representing simple values such as integers, float, characters, etc.
User Defined Data Types The user-defined data types are defined by the user
himself.
Derived Types The data types that are derived from the primitive or built-in
datatypes are referred to as Derived Data Types.
:> The two main categories of software are application software and system
software. An application is software that fulfills a specific need or performs
tasks. System software is designed to run a computer's hardware and provides a
platform for applications to run on top of.
20. Write a note on size of operator and comma operator with example
Example:
// C Program To demonstrate
// sizeof operator
#include <stdio.h>
int main()
{
printf("%lu\n", sizeof(char));
printf("%lu\n", sizeof(int));
printf("%lu\n", sizeof(float));
printf("%lu", sizeof(double));
return 0;
}
The Comma operator allows us to place one or more expression where C syntax allows
only one expression. Each expression must be separated using the comma ( , ) and
are evaluated from left to right. The value of rightmost expression becomes the
value of the overall expression. An example will make everything clear.
#include<stdio.h>
int main()
{
int a, b, c, sum;
sum = (a=3, b=4, c=5, a+b+c);
printf("Sum = %d\n", sum);
// Signal to operating system everything works fine
return 0;
}
23. Explain the arithmetic and increment and decrement operator with example.
:> Increment Operator adds 1 to the operand. Decrement Operator subtracts 1 from
the operand. The Postfix decrement operator means the expression is evaluated first
using the original value of the variable and then the variable is
decremented(decreased).
25. What is pointer? How to declare the pointer variable in program. Explain with
example.
:> A pointer is defined as a derived data type that can store the address of other
C variables or a memory location. We can access and manipulate the data stored in
that memory location using pointers.
In pointer declaration, we only declare the pointer but do not initialize it. To
declare a pointer, we use the ( * ) dereference operator before its name.
Example
int *ptr;
The pointer declared here will point to some random memory address as it is not
initialized. Such pointers are called wild pointers.
int main()
{
// Declare variables
int num1,num2,sum;