Responsive image
Responsive image

COMPUTER SCIENCE SOLUTION OF GRADE 12


What is C Programming Language? List the features of C Language.

C is the high level programming language that was developed by Dennis Ritchie at Bell Telephone Laboratories in 1972. It is also known as middle level programming language because it supports both high and low level features. It is used to develop system software and application software.
Features of C Language are

  • It is a structured programming language which occupies less memory space in computer memory.
  • It has some features of High level and Low level programming  languages. Due to the middle level features it can be used to develop system programs and application programs.
  • It has enough numbers of inbuilt functions and operators.
  • It has variety of data types to represent different kind of data.
  • It is portable programming language.
  • It is easy for debugging, testing and modifying the programs.
  • Its Compiler is easily available.
  • It is general purpose programming language.

 

Write a program to check even or odd number.

/* check whether an input number is even or odd */
#include<stdio.h>
#include<conio.h>
void main()
{
int n, r;
clrscr();
printf(“Enter a number”);
scanf(“%d”,&n);
r = n% 2;
if(r==0)
       printf (“%d is even”,n);
else
       printf(“%d is odd”,n);
getch();
}

 

Write a program to display series from 1 to 50.

#include <stdio.h>
#include<conio.h>
void main( )
{
int i = 1;
clrscr(); 
for (int i=1; i<=50; c++)
{
       Printf(%d,\n”; i); 

getch();
}

 

Write a C language program to calculate and display the monthly interest for following Bank rates
Period <6 month 5%
Period 6 to 12 month 6%
Above 1 year 10%

#include <stdio.h>
#include<conio.h>
void main( )
{
clrscr();
float p,t,r,i;
printf(“\nEnter principal amount”);
scanf(“%f”,&p);
printf(“\nEnter time in month”);
scanf(“%f”,&t);
if(t<6)
       r=5.0;
else if(t<=12)
       r=6.0;
else
       r=10.0;
i=((p*t*r)/100)*12;
printf(“\Monthly interest is %f”,i);
getch();
}

 

 

Write a program to create a user defined function to display the sum of any 2 numbers.

/* To display sum of two numbers using user defined function named sum */

#include<stdio.h>
#include<conio.h>
int sum(int x, int y);
main()
{
clrscr();
int a,b,c;
printf(“\nEnter first number”);
scanf("%d", &a);
printf(“\nEnter second number”);
scanf("%d", &b);
c = sum(a, b);
printf ("sum is = %d\n", c);
return 0;
}

int sum(int x, int y)
{
       return (x + y);
}

 

What are the difference between Array and Struccture in C Language?

The difference between array and structure in C Language are


Sn

Array

 

Structure

1

It is the collection of data items having similar data types

 

It is the collection of data items of dissimilar data types.

2

Each data item is called an element.

 

Each data item is called as member

3

It is built in data type

 

It is user defined data type.

4

It is not possible to define array of of array and structure of array.

 

It is possible to define array of structure.

5

Syntax: data type arrayname[size];

 

Syntax: struct tag_name
{
Data_type member1;
Data_type member2;
…………………….
Data_type member n;
}var;

6

Example:
int x[10];

 

Example:
struct temp
{
int p;
float q;
}x;



Post Your Comment Here