pratian technologies
Company
Programming
Output
write a program to generate the follow 1, -2, 6, -15, 31, -56,....N
Read Solution (Total 8)
-
- #include
int main()
{
int i,k=1,n;
printf("Enter the number of terms : ");
scanf("%d",&n);
printf("1 , ");
for (i = 1; i < n; i++)
{
k = k+(i*i);
if (i % 2 == 0)
printf("%d ,",k);
else
printf("%d ,",-k);
}
return 0;
} - 6 years agoHelpfull: Yes(26) No(3)
- int main()
{
int i,sum=0,n;
scanf("%d",&n);
for(i=1;i - 7 years agoHelpfull: Yes(18) No(57)
- package javasorting;
import java.util.Scanner;
public class SpecialSeries2 {
public static void main(String[] args) {
double a=1;
Scanner kb= new Scanner(System.in);
System.out.println("Enter size of a series");
int sizeOfSeries =kb.nextInt();
System.out.print((int)a+" ");
int count=1;
for(int i=1;i - 6 years agoHelpfull: Yes(3) No(11)
- import java.util.Scanner;
public class Series1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.print("Enter the range: ");
int n = sc.nextInt();
int arr[];
arr = new int[20];
System.out.println("Series : ");
for(int i=0 ; i - 6 years agoHelpfull: Yes(2) No(9)
- this is the logic which could be used:
int b[0]=0,a[1]=1,i,n=N ;
for(i=1;i - 6 years agoHelpfull: Yes(1) No(10)
- #include
int main()
{
int i,j,n,t0=1,t1;
printf("Enter the no of terms require");
scanf("%d",&n);
for(i=0;i - 6 years agoHelpfull: Yes(1) No(2)
- package p2;
import java.util.Scanner;
public class Sequence2 {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
System.out.print("1"+" ");
System.out.print("1"+" ");
int a,b,c;
a=1;
b=1;
for(int i=1;i - 5 years agoHelpfull: Yes(1) No(0)
- #include
void main()
{
int n,I,Sum1=1;
printf("Enter Limit");
scanf("%",&n);
for(I=1;I - 6 years agoHelpfull: Yes(0) No(3)
pratian technologies Other Question