You are on page 1of 9

1. What is Program ?

:> A program is a set of instructions that a computer follows in order to perform a


particular task. [computing]

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.

5. Write down the types of software

:> Application software. ...


System software. ...
Driver software. ...
Middleware. ...
Programming software.

6.How declare the comment line in program

:> // - Single Line Comment.


/*... */ - Multi-line Comment.

7. What is array? Write example

:> 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];

8. To save the program which extension is used?

:> .c

9. What are variables? How it declared.

:> Declaration of Variables. Variables are the basic unit of storage in a


programming language. These variables consist of a data type, the variable name,
and the value to be assigned to the variable

10. How function declared in program write syntax

:> The following is the syntax for defining a function in C: return_type


function_name(parameter_list);

11. Write down the data type name

:> integer, real, character or string, and Boolean.


12. Which header file are used in c program.

:> <assert.h> <errorno.h> <signal.h>

13. What is operating system

:>An operating system is a software package that runs applications and serves as a
communication link (interface) between the computer hardware and the user

14. Who is the father of c language

:> Dennis Ritchie, father of C programming language

15. What is Recursion?

:> the process in which the program repeats a certain section of code in a similar
way

16. Which loop control statment are used in c.

:> The most common loop statements in C are the for loop, the while loop, and the
do-while loop.

17. Which library function used in c ?

:> math. h: mathematical functions, such as sin() and sqrt().

18. Write a note assignment operator with example

:> The assignment operator is used to assign the value, variable and function to
another variable

e.g.> A = 5; // use Assignment symbol to assign 5 to the operand A

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.

21. Write different character set of c.

:> Alphabets.
Digits.
Special characters.
White space.

22. What is string.

:> A String in C programming is a sequence of characters terminated with a null


character '\0'.

Brief question for 5 Marks

1. Explain the features of programming language.


:>A programming language must be simple, easy to learn and use, have good
readability, and be human recognizable.
Abstraction is a must-have Characteristics for a programming language in which the
ability to define the complex structure and then its degree of usability comes.
A portable programming language is always preferred.
Programming language’s efficiency must be high so that it can be easily converted
into a machine code and its execution consumes little space in memory.
A programming language should be well structured and documented so that it is
suitable for application development.A programming language should provide a single
environment known as Integrated Development Environment(IDE).

2. Explain the basic structure of c program .explain with example.

:>Basic Structure of C Program


Section Description
Documentation Includes the program’s description, the programmer’s name, and
the creation date. The majority of these are written as comments.
Link Includes the program’s description, the programmer’s name, and the creation
date. The majority of these are written as comments.
Definition preprocessor directive that contains symbolic constants is included.
For instance, #define enables the usage of constants in our code. In the code, it
substitutes its value for each constant.
Global Declaration Includes the declaration of functions, static global
variables, and global variable declarations.
Main() Function Every C program’s main() function serves as the starting point
for execution. A main() function must be present in every C program.
Subprograms All user-defined methods should be included (functions the user
provides). Both built-in functions and function definitions specified in the Global
Declaration section may be included there. The main() method is what is used for
them.
In order to comprehend the structure of a C program, let’s look at an example:

Example: Write a program to calculate our age.


In the following example, we’ll calculate age concerning a year.

Let’s implement this and check:

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;
}

3. Explain the arithmetic operators with example.


:> Arithmetic Operator is used to performing mathematical operations such as
addition, subtraction, multiplication, division, modulus, etc., on the given
operands. For example: 5 + 3 = 8, 5 - 3 = 2, 2 * 4 = 8, etc. are the examples of
arithmetic operators.

4. What is function? Why function is used in program.

:> In computer programming, a function or subroutine is a sequence of program


instructions that performs a specific task, packaged as a unit. This unit can then
be used in programs wherever that particular task should be performed.

5. Write c program to print “Hello” message on screen.

:>// Simple C program to display "Hello World"

// Header file for input output functions


#include <stdio.h>

// main function -
// where the execution of program begins
int main()
{

// prints hello world


printf("Hello World");

return 0;
}

6. What is local and global variable write with example?

:> What is a Local Variable?


Variables that are declared within or inside a function block are known as Local
variables.
These variables can only be accessed within the function in which they are
declared.
#include<stdio.h>
void main()
{
int x=50, y=40;
printf("x = %d and y=%d",x, y);
}

What is a Global Variable?


Global variables are those variables which are declared outside of all the
functions or block and can be accessed globally in a program.
It can be accessed by any function present in the program.

#include<stdio.h>
int a=50, b=40;
void main()
{
printf("a = %d and b=%d",a,b);
}

7. Explain the types of functions.

:> 1. Library Function


A library function is also referred to as a “built-in function”. A compiler package
already exists that contains these functions, each of which has a specific meaning
and is included in the package. Built-in functions have the advantage of being
directly usable without being defined, whereas user-defined functions must be
declared and defined before being used.

2. User Defined Function


Functions that the programmer creates are known as User-Defined functions or
“tailor-made functions”. User-defined functions can be improved and modified
according to the need of the programmer. Whenever we write a function that is case-
specific and is not defined in any header file, we need to declare and define our
own functions according to the syntax.

8. What is command prompt? Why it is used.

:> Command Prompt is a command line interpreter application available in most


Windows operating systems. It's used to execute entered commands. Most of those
commands automate tasks via scripts and batch files, perform advanced
administrative functions, and troubleshoot or solve certain kinds of Windows
issues.

9. Write a note on constants with example.

:> 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.

// C program to illustrate constant variable definition


#include <stdio.h>

int main()
{

// defining integer constant using const keyword


const int int_const = 25;

// defining character constant using const keyword


const char char_const = 'A';

// defining float constant using const keyword


const float float_const = 15.66;

printf("Printing value of Integer Constant: %d\n",


int_const);
printf("Printing value of Character Constant: %c\n",
char_const);
printf("Printing value of Float Constant: %f",
float_const);

return 0;
}

10. What are the relational operators and logical operators.

:> 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.

11. Write note on compiler.


:> A compiler is a software that converts the source code to the object code. In
other words, we can say that it converts the high-level language to machine/binary
language. Moreover, it is necessary to perform this step to make the program
executable. This is because the computer understands only binary language.

12. Write note on Interpreter.

:> An interpreter is a program that directly executes the instructions in a high-


level language, without converting it into machine code. In programming, we can
execute a program in two ways. Firstly, through compilation and secondly, through
an interpreter.

13. Explain the compiler and linker.

:> 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

14. Explain the data types of c.

:> 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.

15. Write a note on history of c.

:> A successor to the programming language B, C was originally developed at Bell


Labs by Ritchie between 1972 and 1973 to construct utilities running on Unix. It
was applied to re-implementing the kernel of the Unix operating system. During the
1980s, C gradually gained popularity.

16. What is function? What is main function

:> A main is a predefined keyword or function in C. It is the first function of


every C program that is responsible for starting the execution and termination of
the program. It is a special function that always starts executing code from the
'main' having 'int' or 'void' as return data type.

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.

The switch statement consists of conditional-based cases and a default case.

switch(expression)
{
case value1: statement_1;
break;
case value2: statement_2;
break;
.
.
.
case value_n: statement_n;
break;

default: default_statement;
}

18. Explain the different data type.

:> 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.

19. Explain the types of software

:> 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

:> Sizeof is a much-used operator in the C. It is a compile-time unary operator


which can be used to compute the size of its operand. The result of sizeof is of
the unsigned integral type which is usually denoted by size_t. sizeof can be
applied to any data type, including primitive types such as integer and floating-
point types, pointer types, or compound datatypes such as Structure, union, etc.

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;
}

21. Write a c program to display the area of circle.

:> #include <stdio.h>


#include<conio.h>
int main() {
float pie = 3.14;
int radius;
printf("Enter The Radius of Cicle:");
scanf("%d",&radius);
printf("The radius of the circle is %d\n" , radius);
float area = (float)(pie* radius * radius);
printf("The area of the given circle is %f", area);
return 0;
}

22. What is array? One dimensional array with example.

:> A single-dimensional array is a linear structure of elements in C, where each


element stores data of the same data type and can be accessed using an index. For
example, int numbers[5] = {1, 2, 3, 4, 5}; declares an integer array named
'numbers' with a size of 5 elements, containing the values 1 to 5.

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).

24. Write a program in c to calculate the volume of a sphere.

:> #include <stdio.h>


int main()
{
int radius=48;
float pie=3.14285714286;
double volume=(4.0/3.0)*pie*(radius*radius*radius);
printf("Volume of the sphere=%f",volume);
}

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.

26. Write a c program to display the addition of two numbers.

:> #include <stdio.h>

int main()
{
// Declare variables
int num1,num2,sum;

printf("Enter two integers: ");


scanf("%d %d", &num1, &num2);

// calculate the sum of two numbers


sum = num1 + num2;

// Print the result


printf("%d + %d = %d", num1, num2, sum);
return 0;
}

You might also like