0% found this document useful (0 votes)
12 views4 pages

Codes

Codings
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Codes

Codings
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include<stdio.

h>

int main()

char str[100];

gets (str);

int i,j,k=0,count=0;

char str1[100];

for(i=0;str[i]!='\0';i++)

count=0;

for(j=0;j<=i;j++)

if(str[i]==str[j])

count++;

if(count==1)

str1[k]=str[i];

k++;

for(i=0;i<k;i++)

count=0;

for(j=0;str[j]!='\0';j++)

if(str1[i]==str[j])

count++;

if(count==1)

printf("%c",str1[i]);

else
{

printf("%c%d",str1[i],count);

return 0;

OUTPUT

Input : aabbbbeeeeffggg

Output : a2b4e4f2g3

Input : abbccccc

Output : ab2c5

#include<stdio.h>

int main()

int n;

scanf("%d",&n);

int arr[n];

int count;

int i,j,k=0;

for(i=0;i<n;i++)

scanf("%d",&arr[i]);

int newarr[n];

for(i=0;i<n;i++)

count=0;

for(j=0;j<=i;j++)

if(arr[i]==arr[j])

count++;

}
if(count==1)

newarr[k]=arr[i];

k++;

for(i=0;i<k;i++)

count=0;

for(j=0;j<n;j++)

if(newarr[i]==arr[j])

count++;

printf("%d occurs %d times\n",newarr[i],count);

return 0;

OUTPUT

Input : 10

1233414512

Output : 1 occurs 3 times

2 occurs 2 times

3 occurs 2 times

4 occurs 2 times

5 occurs 1 times

#include<stdio.h>

int main()

int a,b;

scanf("%d%d",&a,&b);

int sum;
sum=(a+b)*(a+b)*(a+b);

printf("%d",sum);

OUTPUT

Input : a=10

b=12

Output : 10648 //(10+12)*(10+12)*(10+12)=22*22*22

#include<stdio.h>

int main()

int i,t,cars,bikes;

scanf("%d",&t);

for(i=0;i<t;i++)

scanf("%d%d",&cars,&bikes);

printf("%d\n",cars*4+bikes*2);

OUTPUT

Input : 3

42

Output : 20 (4*4+2*2=16+4)

40

Output : 16 (4*4+0*2=16+0)

12

Output : 8 (1*4+2*2=4+4)

You might also like