Sie sind auf Seite 1von 4

1.

Program in c to print 1 to 100 without using loop

#include<stdio.h>

int main(){
int num = 1;

print(num);

return 0;
}
int print(num){
if(num<=100){
printf("%d ",num);
print(num+1);
}
}

2. Add two numbers without using the plus operator in c

#include<stdio.h>

int main(){

int a,b;
int sum;

printf("Enter any two integers: ");


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

//sum = a - (-b);
sum = a - ~b -1; // ~b= -b+1

printf("Sum of two integers: %d",sum);

return 0;
}

3. C program to display ASCII values

#include<stdio.h>

int main()
{
int i;
for(i=0;i<=255;i++)
printf("ASCII value of character %c: %d\n",i,i);
return 0;
}
4. Determine the frequency of each element in an array of sorted elements.

Example: Input: 1, 1, 4, 4, 5, 6, 7, 7, 7
Output: 1 -> 2
4 -> 2
5 -> 1
6 -> 1
7 -> 3

#include <stdio.h>
int main()
{
int arr[10], F[10], i, j, Count, N;

printf("\n Please Enter Number of elements in an array : ");


scanf("%d", &N);

printf("\n Please Enter %d elements of an Array : ", N);


for (i = 0; i < N; i++)
{
scanf("%d", &arr[i]);
F[i] = -1;
}

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


{
Count = 1;
for(j = i + 1; j < N; j++)
{
if(arr[i] == arr[j])
{
Count++;
F[j] = 0;
}
}
if(F[i] != 0)
{
F[i] = Count;
}
}

printf("\n Frequency of All the Elements in this Array are : \n");


for (i = 0; i < N; i++)
{
if(F[i] != 0)
{
printf("%d -> %d \n", arr[i], F[i]);
}
}
return 0;
}
1. Write a C programme to find the largest element of a given array.
2. Write a C programme to print the largest and the second largest element of an
array.
3. program to divide an array into two arrays of even and odd elements.
4. program to find the number of times a particular element (num) exist in an array.
5. Calculate Sum and Product of all Elements in an array
6. Program to reverse the elements in given Array.
7. Merge two one dimensional array elements in one dimensional third array
8. To add and subtract of two one dimensional array elements and store it in a third and fourth one
dimensional array and print it
9. C Program to Calculate mean of 10 numbers
10. C program to find the first repeated element in an array

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


{
for(j=i+1;j<n;j++)
{

if(arr[i]==arr[j])
{
ind=j;
ele=arr[i];
}
}}
if(ind!=-1)
printf("%d repeated at index %d\n",ele,ind);
else
printf("There is no repeated element\n");

11. which reads a square matrix a[n][n] and print only the elements that falls in the diagonal
starting from a[0][0] to a[n][n] and all other elements printed as 0 (zero).
12. which computes and prints the sum of each rows of a 2D Matrix.
13. C program to count frequency of each element of an array
14. find number of blank space in a sentence
15. C program to count total number of vowel or consonant in a string
17.

5. What will be output when you will execute following c


code?
#include<stdio.h>
void main(){
char arr[7]="Network";
printf("%s",arr);
}

Answer: Garbage

Das könnte Ihnen auch gefallen