CODEx

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

/*

* mangaskid.c
*
* Created on: Feb 12, 2021
* Author: Computer Lab One
*/
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void){
int f1=0,f2=0,f3=0,f4=0,f5=0,f6=0,i,d;
for(i=0;i<100;i++){
d=1+rand()%6;

switch (d){
case 1:
f1++; break;
case 2:
f2++; break;
case 3:
f3++; break;
case 4:
f4++; break;
case 5:
f5++; break;
case 6:
f6++; break;

}
}

ENCRYPT

/*
* enc.c
*
* Created on: Feb 5, 2021
* Author: Computer Lab One
*/

#include<stdio.h>
int encrypt(int n){
int i,j,k,m=0;
int a[4];
int c=1000;
for(i=0;i<4;i++){
a[i]=n/c;
n=n%c;
c=c/10;
}
for(j=0;j<4;j++){
a[j]=(a[j]+7)%10;

}
for(k=0;k<2;k++){
int temp=a[k];
a[k]=a[k+2];
a[k+2]=temp;
}
for(i=0;i<4;i++){
int e=1000;
m=m+a[i]*e;
e=e/10;

}
return m;
}

int main(void){
int d;
printf("%s","enter four digits number\n");
scanf("%d",&d);
int x=encrypt(d);
printf("%d\n",x);
}

SORT

/*
* sort.c
*
* Created on: Feb 12, 2021
* Author: Computer Lab One
*/
#include<stdio.h>
int main (void){
int i,j,temp;
int s[6]={100,50,70,85,40,30};
for(i=0;i<6;i++){
for(j=i+1;j<6;j++){
if(s[i]>s[j]){
temp=s[i];
s[i]=s[j];
s[j]=temp;

}
}
}
i=0;
for(i=0;i<6;i++)
printf("%d\t",s[i]);
}

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

void Sort(int x []){

int A;

int a,b,temp;

for (a=0; a<100; a++){

if (A[a]>A[b]){

temp = A[a];

A[a]=A[b];

A[b]= temp;}}}

int main(void)

int i,j,S[100];
for (i=0; i<100; i++){

A[i]=1+rand()%100;

for (j=0; j<100; j++){

printf("%d\t , s[j]");

if (j%10==0)

printf("\n");

int A=0,B=0,C=0,D=0,E=0;

for (i=0; i<100; ++){

if (A[i]>=70)

A=A+1;

else if (B[i]>=60)

B=B+1;

else if (C[i]>=50)

C=C+1;

else if (D[i]>=45)

D=D++;

else if (E[i]>40)

E=E++;
else

E++;

printf("\nSn\t\tnumber of students\t\tGrade\t\tHistogram\n");

printf("1\t\t%d\t\t%s\t\t,A,"A");

for (i=0; i<A; i++){

printf("*");

printf("\n");

You might also like