Professional Documents
Culture Documents
LAB 1
scanf("%d",&t);
Ex 4 h= t/3600;
#include<stdio.h> m= (t - 3600*h)/60;
main() s= (t-3600*h-60*m);
scanf("%d%d",&a,&b);
a= a + b; Ex 6
b= a-b; #include<stdio.h>
a= a-b ; main()
Ex 5 Dollar\n");
int t, h, m, s; }
printf("your character %c is a special Ex 3
LAB 2
character", c); #include<stdio.h>
Ex 1 } main()
#include<stdio.h> {
printf("your character is %c=%d \n", c, c ); printf ("enter three numbers a, b and c\n"); else
if (c>= 'a' && c <= 'z') scanf("%f%f%f", &a, &b, &c); if (s<10000 && s<2000)
if (c>= 'A' && c <= 'Z') if (b>a && b>c) printf("%.2f is the gross salary", gs);
c); else
else
Ex 4 sr= sqrt(sum); break;
int sum, a, b, c, d, power; printf("the power is %d\n ", power); printf("its a vowel");
break; {
default: break ;
} s= a-b;
break ;
Ex 2 case '*':
#include<stdio.h> s= a*b;
{ form of n*m\n"); }
if (t[i]== v) scanf("%d,%d",&n,&m); }
} { C[row][col]=s;
} for(col=0;col<m;col++) s=0;
} } for (row=0;row<n;row++)
{ { }
#include <stdlib.h> { {
scanf("%d,%d",&n,&m); } }
randomly\n"); } }
{ {
for(column=0;column<m;column++) for(column=0;column<m;column++)
{ {
{ {
printf("%d|", T[row][column]); }
} }
} printf("\n");
printf("\n"); }
} printf("\n");
{ printf("After concatenation the string is : \n
Lab5 Strings
char str1[100], str2[100], i, j,l,m,k; ");
Exercice 1: printf("Concatenate Two Strings for(i=0; i<k; ++i)
#include<stdio.h> Manually :\n"); {
main() printf("-------------------------------------\n"); printf("%c",str1[i]); } }
{ printf("Input the first string : "); Exercice 3 :
char s1[100], s2[100]; gets(str1); #include<stdio.h>
int i; printf("Input the second string : "); main(){
printf("Enter string s1: "); gets(str2); char line[150];
scanf("%s",s1); l=strlen(str1); /* int i,v,c,ch,d,s,o;
for(i=0; s1[i]!='\0'; ++i) m=strlen(str2); o=v=c=ch=d=s=0; */
{ for(i=0; i<l-1; ++i); /* value i contains int i,v,c,d,s;
s2[i]=s1[i]; reaches the end of string str1. */ v=c=d=s=0;
} str1[i]=' '; /* add a space with string str1. */ printf("Enter a line of string:\n");
s2[i]='\0'; i++; /* value i increase by 1 for the blank gets(line);
printf("String s2: %s",s2); space */ for(i=0;line[i]!='\0';++i)
} for(j=0; j<m-1; ++j, ++i) {
Exercise 2: { if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
#include <stdio.h> str1[i]=str2[j]; line[i]=='o' || line[i]=='u' || line[i]=='A' ||
#include <string.h> } line[i]=='E' || line[i]=='I' || line[i]=='O' ||
main() k=strlen(str1); line[i]=='U')
++v; #include <stdio.h> void main(){
else if(line[i]>='0'&&c<='9') char str[100]; /* Declares a string of size 100 Except Alphabets :\n");
++d; */ printf("---------------------------------------------
Exercise 2: } if(T[i]==X)
/******function void Fill_array(int T[], int int Lookup(int T[], int N, int X) }
{ for(i=0;i<N;i++) main()
printf("T[%d]=\t",i); break; }
scanf("%d",&T[i]); } while(N<0);
void DisplayArray (int T[],int N) /*find the Occurence value x in the array */ DisplayArray(T, N);
int i; { scanf("%d",&v);
}while((n <= 0) || (n > 10)); for(int i = 0; i < columns; i++){ int rows, columns;
columns) } transposedMatrix(transposed,tab, n, n) ;
//int M1[50][50]; }}
srand(time(NULL)) ;