Difference between perfect square and a number that can be expressed as product of consecutive integers:

Image
A perfect square is a number that can be expressed as the product of an integer by itself or as the second exponent of an integer¹. For example, 1, 4, 9, and 16 are perfect squares because they are the squares of 1, 2, 3, and 4 respectively. A perfect square can also be written as x^2, where x is an integer. A number that can be expressed as a product of consecutive integers is a number that can be obtained by multiplying two or more integers that follow each other in order. For example, 6, 24, and 120 are numbers that can be expressed as products of consecutive integers because they are equal to 2 x 3, 2 x 3 x 4, and 2 x 3 x 4 x 5 respectively. A number that can be expressed as a product of consecutive integers can also be written as x(x + 1)(x + 2)...(x + n), where x and n are integers. The difference between a perfect square and a number that can be expressed as a product of consecutive integers is that a perfect square has only one factor pair that consists of the same integer, whi

CP Open ended Lab:

   

Just copy the below code to print the above output:


#include<stdio.h>

int main()
{
char str[25] = {"abcdabcdabcdabcdabcdabcd"};
char str_1[25], str_2[25], str_3[25];
printf("Please provide the str[25] without any space: %s",str);
printf("\n\nInput response of student 1:\t");
gets(str_1);
if (strlen(str_1) !=24)
{
printf("invailed length please enter correct length");
return 0;
}
int marks = 0, wrong_num = 0, i=0;
int position[25];
for(i=0; i<25; i++)
{
if(str[i] == str_1[i])
{
marks++;
}
else
{
position[wrong_num] = 1+i;
wrong_num++;
}
}
printf("\nStudent_1:\n");
printf("\nTotal score is %d out of 25",marks);
if(wrong_num==0)
{
printf("\n Nill");
}
else
{
printf("\nResponse to the following character are wrong\n");
for(i=0;i<wrong_num;i++)
{
printf("%d ",position[i]);
}
}

printf("\n\nInput response of student 2:\t");
gets(str_2);
if (strlen(str_2) !=24)
{
printf("invailed length please enter correct length");
return 0;
}
marks = 0, wrong_num = 0;
for(i=0; i<25; i++)
{
if(str[i] == str_2[i])
{
marks++;
}
else
{
position[wrong_num] = 1+i;
wrong_num++;
}
}
printf("\nStudent_2\n");
printf("\nTotal score is %d out of 25",marks);
if(wrong_num==0)
{
printf("\n Nill");
}
else
{
printf("\nResponse to the following character are wrong\n");
for(i=0;i<wrong_num;i++)
{
printf("%d ",position[i]);
}
}
printf("\n\nInput response of student 3:\t");
gets(str_3);
if (strlen(str_3) !=24)
{
printf("invailed length please enter correct length");
return 0;
}
marks = 0, wrong_num = 0;
for(i=0; i<25; i++)
{
if(str[i] == str_3[i])
{
marks++;
}
else
{
position[wrong_num] = 1+i;
wrong_num++;
}
}
printf("\nStudent_3:\n");
printf("\nTotal score is %d out of 25",marks);
if(wrong_num==0)
{
printf("\n Nill");
}
else
{
printf("\nResponse to the following character are wrong\n");
for(i=0;i<wrong_num;i++)
{
printf("%d ",position[i]);
}
}
return 0;
}



Comments

Popular posts from this blog

C language program to find prime number

What is a computer language